package com.park.service.impl;

import com.park.bean.Tickets;
import com.park.bean.TicketsCap;
import com.park.dao.ITicketsCapDao;
import com.park.service.ITicketsCapService;
import com.park.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@Service
public class TicketsCapServiceImpl implements ITicketsCapService {
    @Autowired
    ITicketsCapDao dao;
    @Override
    public List<TicketsCap> getTicketsCap(TicketsCap ticketsCap, Page page) {
        System.out.println(ticketsCap.getAttractsName());
        return dao.getTicketsCap(ticketsCap,page);
    }

    @Override
    public List<Integer> getTicketsId(TicketsCap ticketsCap) {
        return dao.getTicketsId(ticketsCap);
    }

    @Override
    public List<Tickets>  getTicketsByName(String string){
        return dao.getTicketsByName(string);
    }

    @Override
    public List<String> getAttractsName(TicketsCap ticketsCap) {
        return dao.getAttractsName(ticketsCap);
    }

    @Override
    public boolean duplicateCheck(TicketsCap ticketsCap) {
        System.out.println("233");
        int count=dao.duplicateCheck(ticketsCap);
        if(count>0)
            return false;
        else
            return true;
    }

    @Override
    public boolean checkTid(Integer id){
        System.out.println(id);
        List<Integer> list=dao.checkTid(id);
        System.out.println("!!!!!!!!!!"+list.size());
        for (Integer integer : list) {
            System.out.println(integer);
        }
        if(list.size()==1){
            if(Objects.equals(id, list.get(0)))
            {
                return true;
            }else {
                return false;
            }
        }else{
            return false;
        }
    }

    @Override
    public boolean checkTname(String name){
        List<String> list=dao.checkTname(name);
        if(list.size()==1){
            if(list.get(0).equals(name))
            {
                return true;
            }else {
                return false;
            }
        }else{
            return false;
        }
    }

    public boolean checkAname(String name){
        System.out.println(name);
        List<String> list=dao.checkAname(name);
        System.out.println("!!!!!!!!!!"+list.size());
        if(list.size()==1){
            if(list.get(0).equals(name))
            {
                return true;
            }else {
                return false;
            }
        }else{
            return false;
        }
    }

    @Override
    public int getCount(TicketsCap ticketsCap) {
        return dao.getCount(ticketsCap);
    }

    @Override
    public int delTicketsCap(int id) {
        return dao.delTicketsCap(id);
    }

    @Override
    public int postTicketsCap(TicketsCap ticketsCap) {
        return dao.postTicketsCap(ticketsCap);
    }

    @Override
    public int editTicketsCap(TicketsCap ticketsCap) {
        return dao.editTicketsCap(ticketsCap);
    }
}
